import { createRouter, createWebHashHistory } from "vue-router"

const router = createRouter({
    history: createWebHashHistory(),
    routes: [
        {
            path: "/",
            // 页面启动直达
            redirect: "/findMusic/recommend",
            component: () => import("../pages/findMusic/findMusic.vue")
        },
        {
            path: "/findMusic",
            name: "findMusic",
            component: () => import("../pages/findMusic/findMusic.vue"),
            redirect: "/findMusic/recommend",
            children: [
                {
                    path: "/findMusic/recommend",
                    name: "recommend",
                    component: () => import("../pages/findMusic/children/index-recommend/indexRecommend.vue")
                },
                {
                    path: "/findMusic/customization",
                    name: "customization",
                    component: () => import("../pages/findMusic/children/customization/customization.vue")
                },
                {
                    path: "/findMusic/songList",
                    name: "songList",
                    component: () => import("../pages/findMusic/children/song-list/songList.vue")
                },
                {
                    path: "/findMusic/rankingList",
                    name: "rankingList",
                    component: () => import("../pages/findMusic/children/ranking-list/rankingList.vue")
                },
                {
                    path: "/findMusic/singer",
                    name: "singer",
                    component: () => import("../pages/findMusic/children/singer/singer.vue")
                },
                {
                    path: "/findMusic/newMusic",
                    name: "newMusic",
                    component: () => import("../pages/findMusic/children/new-music/newMusic.vue")
                }
            ]
        },
        {
            path: "/podcast",
            name: "podcast",
            component: () => import("../pages/podcast.vue")
        },
        {
            path: "/video",
            name: "video",
            component: () => import("../pages/video.vue")
        },
        {
            path: "/attention",
            name: "attention",
            component: () => import("../pages/attention.vue")
        },
        {
            path: "/liveStreaming",
            name: "liveStreaming",
            component: () => import("../pages/liveStreaming.vue")
        },
        {
            path: "/privateFM",
            name: "privateFM",
            component: () => import("../pages/privateFM.vue")
        },
        {
            path: "/song-list-info",
            name: "songListInfo",
            component: () => import("../components/songListInfo/songListInfo.vue"),
            redirect: "/song-list-info/singList",
            children: [
                // 歌曲列表
                {
                    path: "/song-list-info/singList",
                    name: "singList",
                    component: () => import("../components/songListInfo/children/getSingList/getSingList.vue")
                },
                {
                    path: "/song-list-info/singComment",
                    name: "singComment",
                    component: () => import("../components/comment/commentInfo.vue")
                },
                {
                    path: "/song-list-info/singCollector",
                    name: "singCollector",
                    component: () => import("../components/collector/collector.vue")
                }
            ]
        },
        // 空白路由
        {
            path: "/refresh",
            name: "refresh",
            component: () => import("../components/refresh/refresh.vue")
        },
        {
            path: "/search-info-list",
            name: "searchInfoList",
            component: () => import("../pages/searchInfoList/searchInfoList.vue"),
            redirect: '/search-info-list/searchSingle',
            children: [
                {
                    path: "/search-info-list/searchSingle",
                    name: "searchSingle",
                    component: () => import("../pages/searchInfoList/children/searchSingle.vue")
                },
                {
                    path: "/search-info-list/searchSinger",
                    name: "searchSinger",
                    component: () => import("../pages/searchInfoList/children/searchSinger.vue")
                },
                {
                    path: "/search-info-list/searchAlbum",
                    name: "searchAlbum",
                    component: () => import("../pages/searchInfoList/children/searchAlbum.vue")
                },
                {
                    path: "/search-info-list/searchVideo",
                    name: "searchVideo",
                    component: () => import("../pages/searchInfoList/children/searchVideo.vue")
                },
                {
                    path: "/search-info-list/searchSongList",
                    name: "searchSongList",
                    component: () => import("../pages/searchInfoList/children/searchSongList.vue")
                },
                {
                    path: "/search-info-list/searchLyric",
                    name: "searchLyric",
                    component: () => import("../pages/searchInfoList/children/searchLyric.vue")
                },
                {
                    path: "/search-info-list/searchVoice",
                    name: "searchVoice",
                    component: () => import("../pages/searchInfoList/children/searchVoice.vue")
                },
                {
                    path: "/search-info-list/searchAudio",
                    name: "searchAudio",
                    component: () => import("../pages/searchInfoList/children/searchAudio.vue")
                },
                {
                    path: "/search-info-list/searchUser",
                    name: "searchUser",
                    component: () => import("../pages/searchInfoList/children/searchUser.vue")
                }
            ]
        }
    ]
})

export default router

/**
 * 路由权限
 * 
 * router.beforeEach((to,from,next)=>{
 *     if(to.meta.roles.includes(role)){
 *          放行
 *          next()
 *      }else{
 *           不放行
 *      }
 * })
 */